package com.nebula.salary.model.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

/**
 * 分页查询数据传输类
 *
 * @author codex
 * @since 2022-02-12
 */
@ApiModel(value = "PageDto对象", description = "分页查询数据传输类")
public class PageDto implements Serializable {
    private static final long serialVersionUID = -2128762468890142312L;
    
    @ApiModelProperty(value = "当前页", position = 1)
    private Long page;
    
    @ApiModelProperty(value = "页面条数", position = 2)
    private Long limit;
    
    @ApiModelProperty(value = "排序字段名", position = 3)
    private String field;
    
    @ApiModelProperty(value = "排序方式", position = 4)
    private boolean asc;
    
    public PageDto() {
    }
    
    public PageDto(Long page, Long limit) {
        this.page = page;
        this.limit = limit;
    }
    
    public PageDto(Long page, Long limit, String field, boolean asc) {
        this.page = page;
        this.limit = limit;
        this.field = field;
        this.asc = asc;
    }
    
    public String getField() {
        return field;
    }
    
    public void setField(String field) {
        this.field = field;
    }
    
    public boolean isAsc() {
        return asc;
    }
    
    public void setAsc(boolean asc) {
        this.asc = asc;
    }
    
    public Long getPage() {
        if (page == null || page <= 0) {
            page = 1L;
        }
        return page;
    }
    
    public void setPage(Long page) {
        this.page = page;
    }
    
    public Long getLimit() {
        if (limit == null || limit <= 0) {
            limit = 10L;
        }
        return limit;
    }
    
    public void setLimit(Long limit) {
        this.limit = limit;
    }
}
